import { Exclude } from "class-transformer";
import { Column } from "typeorm";
import { PrimaryGeneratedColumn } from "typeorm";
import { Entity } from "typeorm";
import { hashSync } from "bcryptjs"
import { BadRequestException } from "@nestjs/common";
@Entity()
export class UserDemo {

    @PrimaryGeneratedColumn()
    id: number

    @Column({
        unique: true
    })
    username: string

    // @Exclude() 没什么用啊
    // @Exclude()

    @Column({
        select: false,
        transformer: {
            from(value) {
                return value
            },

            to(value) {
                return value ? hashSync(value) : value
            }
        }
    })
    password: string
}